//
//  ViewController.m
//  UI21_SQLite
//
//  Created by Scott on 16/1/11.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "DataBaseHandler.h"
#import "Student.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


- (IBAction)handleOpen:(id)sender {
    
    NSLog(@"%@", NSHomeDirectory());
    
    [[DataBaseHandler shareDataBaseHandler] open];
    
}

- (IBAction)handleCreate:(id)sender {
    
    [[DataBaseHandler shareDataBaseHandler] createTable];
}

- (IBAction)handleInsert:(id)sender {
    
    Student *stu = [[Student alloc] init];
    stu.name = @"zhangsan";
    stu.sex = @"male";
    stu.age = 18;
    
    [[DataBaseHandler shareDataBaseHandler] insertStudent:stu];
    
}

- (IBAction)handleUpdate:(id)sender {
    
    Student *stu = [[Student alloc] init];
    stu.name = @"lisi";
    stu.sex = @"female";
    stu.age = 20;
    
    [[DataBaseHandler shareDataBaseHandler] updataStudent:stu forNumber:1];
    
    
}

- (IBAction)handleDelete:(id)sender {
    
    [[DataBaseHandler shareDataBaseHandler] deleteWithNumber:10];
    
}

- (IBAction)handleSelect:(id)sender {
    
    NSArray *arr = [[DataBaseHandler shareDataBaseHandler] selectForAge:18];
    
    NSLog(@"%@", arr);
    
}

- (IBAction)handleDrop:(id)sender {
    
    [[DataBaseHandler shareDataBaseHandler] dropTable];
}

- (IBAction)handleClose:(id)sender {
    
    [[DataBaseHandler shareDataBaseHandler] closeDB];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
